var layer;
layui.use(["layer"],function(){
	layer = layui.layer;
});
function del(name,is_folder){
	$.ajax({
	　　type : "DELETE",
	　　url : '/',
	　　dataType : "json",
		data: {name:name,folder:is_folder},
	　　success : function(res) {
			console.log(res)
		    if(res.code==200){
				location.reload();
			}
		},
		error:function(xhr,state,errorThrown){
			console.log(xhr,state,errorThrown)
			layer.msg(xhr.responseJSON.msg,{icon:5})
		},
		complete: function (xhr) {
			// console.log(xhr)
		}
	});
}
function modifyPwdContent(){
	return [
		'<div style="padding-top:32px;">',
		'	<div class="layui-form-item">',
		'		<label class="layui-form-label" style="width:90px;padding:9px 5px;">文件夹名称</label>',
		'		<div class="layui-input-block">',
		'		  <input style="width:90%;color:#333333;" type="text" name="old_pwd" placeholder="请输入文件夹名称" autocomplete="off" class="layui-input" />',
		'		</div>',
		'	</div>',
		'</div>'
	].join('');
};
function create_folder(path){
	layer.open({
		title:"创建文件夹",
		type: 1,
		content: this.modifyPwdContent(),
		area: ["330px","190px"],
		anim:2,
		btn:['创建','取消'],
		yes:function(index){
			let oldPwd = $('input[name="old_pwd"]').val();
			if(oldPwd==""){
				layer.msg("请输入文件夹名称",{icon:2,time:1500,id:'tips_dialog'});
				return;
			}
			$.ajax({
			　　type : "PUT",
			　　url : location.origin+path,
			　　dataType : "json",
				data: {dir:oldPwd.replaceAll(" ","_")},
			　　success : function(res) {
					console.log(res)
					if(res.code==200){
						location.reload();
					}
				},
				error:function(xhr,state,errorThrown){
					console.log(xhr,state,errorThrown)
				},
				complete: function (xhr) {
					// console.log(xhr)
				}
			});
		}
	});
}
function checkFile() {
    var file = document.getElementsByName('file')[0].value;
    if (file == null || file == "") {
        layer.msg("请选择要上传的文件!",{icon:5,time:2000});
        return false;
    }
}